//
//  ZSWechatTimeLineCell.swift
//  creativeassistant
//
//  Created by 灵工邦 on 2025/2/10.
//

import UIKit
import Toast_Swift

class ZSWechatTimeLineCell: UITableViewCell {
    
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var functionView: UIView!
    @IBOutlet weak var functionHeight: NSLayoutConstraint!
    
    var model: ZSWechatTimeLineModel? {
        didSet {
            guard let model = model else { return }
            contentLabel.text = model.content
            functionView.isHidden = model.isSelect ? false : true
            functionHeight.constant = model.isSelect ? 40 : 0
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        functionHeight.constant = 0
    }
    
    @IBAction func didCopy(_ sender: UIButton) {
        if let model = model, !model.content.isEmpty {
            UIPasteboard.general.string = model.content
            UIApplication.topViewController()?.view.makeToast("复制成功", position: .center)
        }
    }
    
    @IBAction func didCreation(_ sender: UIButton) {
        let vc = ZSAssistantViewController()
        vc.aiIdentity = 4
        vc.wechatTimeLineTemplate = "参照句子，创作类似小清新文案5个，原句如下：\(model?.content ?? "")"
        UIApplication.topViewController()?.navigationController?.pushViewController(vc, animated: true)
    }
    
}
